package com.peas.platform.common.core.configuration;

import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.convert.converter.Converter;
import org.springframework.lang.NonNull;

@Slf4j
public class ConverterBoolean implements Converter<String, Boolean> {

	@Override
	public Boolean convert(@NonNull String source) {
		log.debug("ConverterBoolean, source:" + source);
		if (StrUtil.isBlank(source)) {
			return null;
		}
		if ("true".equalsIgnoreCase(source.trim())) {
			return Boolean.TRUE;
		} else {
			return Boolean.FALSE;
		}
	}

}
